/* 
 * File:   chessboard.h
 * Author: gustavo
 *
 * Created on October 29, 2011, 5:55 AM
 */

#ifndef CHESSBOARD_H
#define	CHESSBOARD_H

#ifdef	__cplusplus
extern "C" {
#endif
#include "../image.h"
#include "../../geometry/geometry.h"
#include "../../matrix/matrix.h"

	typedef struct _chess_grid ChessGrid;

	struct _chess_point {
		real x, y;
		real gx, gy;
	};

	struct _chess_grid {
		int size;
		struct _chess_point * points;
	};

	boolean imp_image_calib_find_partial_chessboard(ImpMatrix * Mat, ImpMatrix ** Xr, ImpMatrix ** Xi);
	ChessGrid * create_chessboard_correspondence(ImpSurface * surf, ImpMatrix * BW);
	void extract_matrices_from_chessgrid(ChessGrid * cgrid, ImpMatrix ** Xr, ImpMatrix ** Xi);
	void update_points_to_sub_pixel(ImpMatrix * Mat, ImpMatrix * X);
	void filt_chessboard(ImpSurface * surf, ImpMatrix * BW);
	
	void imp_image_chessboard_draw_grid(ImpImage * iRGB, ImpMatrix * X, ImpMatrix * Xi, boolean draw_line);
	
	ImpMatrix * get_search_grid(ImpMatrix * pXr, int width, int height, ImpMatrix * H);
	
	boolean chess_detect(ImpMatrix * Mat, int w, int h, ImpMatrix ** _Xi, ImpMatrix ** _Xw);
	
	void axda(ImpMatrix * Mat, ImpMatrix ** Xda, int w, real T);
	

#ifdef	__cplusplus
}
#endif

#endif	/* CHESSBOARD_H */
